Essential for Beginners: Basics of Linux Network Configuration
This article introduces the necessity and practical methods of Linux network configuration. For newcomers, mastering network configuration is fundamental for using servers and setting up services. They need to first understand four key elements: IP address (the "ID" of a device), subnet mask (network segment identifier), gateway (entrance/exit between internal and external networks), and DNS (domain name translation). Common commands to check network status include: `ip addr` to view IP addresses, `route -n` to check routes, and `ping` to test connectivity (including local loopback and external network verification). For dynamic IP configuration (DHCP), use the `nmcli` tool to modify connection parameters and activate them. For static IP configuration, prepare parameters such as IP, subnet mask, gateway, and DNS in advance. On CentOS, set static IPs in the `/etc/sysconfig/network-scripts/ifcfg-eth0` file, while Ubuntu uses `netplan` to configure the `01-netcfg.yaml` file. After configuration, verification steps include: using `ip addr` to confirm the IP, `ping` to test local/gateway/external network connectivity, and `nslookup` to test DNS. Common issues like IP conflicts or failure to ping the gateway can be troubleshooted by following the steps: "check IP → verify routes → ping tests". The core lies in understanding the four key elements and practicing commands like `ip` and `ping` regularly.
Read More